const BaseMapper = require("../../library/base-mapper");
const Model = require("../model/user");
const {Op} = require("sequelize");

module.exports = class UserMapper extends BaseMapper{
    constructor() {
        super();
        this.model = Model
    }

    handleSearch(params, options) {
        if(params['username']){
            options.where['username'] = {
                [Op.substring]: params['username']
            }
        }
        if(params['password']){
            options.where['password'] = {
                [Op.substring]: params['password']
            }
        }

        if(params['game_id']){
            options.where['game_id'] = {
                [Op.eq]: params['game_id']
            }
        }

        if(params['anchor_id']){
            options.where['anchor_id'] = {
                [Op.eq]: params['anchor_id']
            }
        }

        super.handleSearch(params, options)
    }
}